<!DOCTYPE html>
<html lang="ar">
<head>
    <title>الاتفاقيات</title>
	<?php
	 define('LAST_CAPITRE_ID',19);
	 define('LAST_ARTICLE_CODE',3);
	?>

	<?php $this->load->helper('url');?>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta charset="utf-8">

<!---------------------for autocomplete--------------->
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-1.11.0.min.js');?>" ></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-ui-1.10.4/js/jquery-ui-1.10.4.min.js');?>" ></script>
	<link href="<?php echo base_url("assets/css/jquery-ui.css")?>" rel="stylesheet" type="text/css" />
	<!------------------------------------------------------>

<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.tablesorter.min.js');?>" ></script>
		<link href="<?php echo base_url("assets/css/table.css")?>" rel="stylesheet" type="text/css" />
	<link href="<?php echo base_url("assets/css/ch_menu.css")?>" rel="stylesheet" type="text/css" />
	 <link href="<?php echo base_url("assets/css/botton.css")?>" rel="stylesheet" type="text/css" />
	
</head>


<?php include_once('header.php');

		//$r=$les_convention;
		 $this->load->library('session');
        $num_ar=$this->session->userdata('data_charticle'); //access it
        $chcl=$num_ar;
 ?>
 

<?php
$liste_des_fournisseurs= array();
foreach ($results_recherche as $lf){
	array_push($liste_des_fournisseurs, $lf->nom);
	}
	
$m=0;
	?>
	
	<br><br>

	<form id="recherche_frm" method="post" action="<?php echo base_url("convention_crt/find_convention_per_fournis/");?>" style="width: 30%; display:inline-block;">
	  <fieldset>
	  <label for="nom" style="font-size: 120%">بحث بالمورد </label><br>
				<input id="nom" name="nom" type="text" value="<?php
				if($results_recherche){
				 echo($results_recherche[0]->nom);	
				}
				
				 
				 ?>">
				 
       
		 <button type="submit" id="submit_btn" class="pure-button pure-button-primary">بحث</button>
		  </fieldset>
		 
	</form>
	
<!--////////////////////
////////////////////
/////////////////
/////////////////-->


	<form action="<?php echo base_url("convention_crt/find_convention_per_date/");?>"  method="POST" style="width: 30%; display:inline-block;">
	   <fieldset>
	    <label for="nom" style="font-size: 120%">بحث  بالتاريخ </label><br>
		
		<SELECT name="mois2" Size="1">
		<?php
			for($d=1; $d<=12;$d++)
			{	       //Lister les mois
				if ($d < 10)
				{		       //Lister les jours pour pouvoir leur ajouter un 0 devant
					echo "<OPTION>0$d<br></OPTION>";
				}
				else 
				{
					echo "<OPTION>$d<br></OPTION>";
				}
            }
		?>
		</SELECT>
		 <SELECT name='jour2' Size='1'>
		<?php
			for($i=1; $i<=31;$i++)
			{	       //Lister les jours
				if ($i < 10)
				{		       //Lister les jours pour pouvoir leur ajouter un 0 devant
					echo "<OPTION>0$i<br></OPTION>";
				}
				else 
				{
					echo "<OPTION>$i<br></OPTION>";
				}
            }
			?>
		</SELECT>	
		<label for="nom">من : </label>
		     
		<SELECT name='jour1' Size='1'>
		<?php
			for($i=1; $i<=31;$i++)
			{	       //Lister les jours
				if ($i < 10)
				{		       //Lister les jours pour pouvoir leur ajouter un 0 devant
					echo "<OPTION>0$i<br></OPTION>";
				}
				else 
				{
					echo "<OPTION>$i<br></OPTION>";
				}
            }
			?>
		</SELECT>
		<SELECT name="mois1" Size="1">
		<?php
			for($d=1; $d<=12;$d++)
			{	       //Lister les mois
				if ($d < 10)
				{		       //Lister les jours pour pouvoir leur ajouter un 0 devant
					echo "<OPTION>0$d<br></OPTION>";
				}
				else 
				{
					echo "<OPTION>$d<br></OPTION>";
				}
            }
		?>
		</SELECT>
		 
		<label for="nom">الى </label>
		
		<input type="submit" value="بحث"><br/>
		
		 </fieldset>
		</form>
	
	
	<!--////////////////////
////////////////////
/////////////////
/////////////////-->

<form id="recherche_frm" method="post" action="<?php echo base_url("convention_crt/find_convention_per_wilaya/");?>" style="width: 30%; display:inline-block;">
	  <fieldset>
	 <label for="nom" style="font-size: 120%">بحث بالولاية </label>	<br>
		<SELECT name="wilaya" Size="1">
		<?php
			foreach($wilaya as $data) 
			{	       //Lister les mois
				
					echo "<OPTION>$data->nom_ar<br></OPTION>";
				
            }
		?>
		</SELECT>
		
		<input type="submit" value="بحث"><br/>
			
	 </fieldset>	 
	</form>
	
	<!--////////////////////
////////////////////
/////////////////
/////////////////-->

<div class = "charticle_browser">
	
<ul class="topmenu" id="css3menu1">
<?php

$mem =0;


for($i = 0; $i < count($chcl); $i++)
{
	if($mem <> $chcl[$i]->id_chapitre)
			{	
				echo('<li class="topmenu"><a style="width:248px;" href="#"><span>
				<img alt="" src="images/sparkle-brown-vertical/info2.png">'. $chcl[$i]->ch_code.' - '.$chcl[$i]->nom_chap.'</span></a>');
				echo('<div style="auto;" class="submenu">');
				echo('<div style="width:100%" class="column">');

			
				echo('<ul><li><a href="'.base_url("convention_crt/get_convention_per_article2/").'/'.$chcl[$i]->id_article.'">
				<img alt="" src="images/sparkle-brown-vertical/bookmarks.png">'.$chcl[$i]->code.'- '.$chcl[$i]->nom_art.'</a></li><br>');

				if(($chcl[$i]->code)== 1 && ($chcl[$i]->id_chapitre == 16))  echo('</ul></div></div></li>'); // patch to fix a unique child
				
			}
			else
			{

				
				echo('<li><a href="'.base_url("convention_crt/get_convention_per_article2/").'/'.$chcl[$i]->id_article.'">
				<img alt="" src="images/sparkle-brown-vertical/bookmarks.png">'.$chcl[$i]->code.'- '.$chcl[$i]->nom_art.'</a></li><br>');

				if($chcl[$i+1]->id_chapitre > $mem) echo('</ul></div></div></li>');
				if(($chcl[$i]->code)== 2 && ($chcl[$i]->id_chapitre == 19))  //if last chapitre et article
				 {

				 
				 	echo('<li><a href="'.base_url("convention_crt/get_convention_per_article2/").'/'.$chcl[$i]->id_article.'">
					<img alt="" src="images/sparkle-brown-vertical/bookmarks.png">'.$chcl[$i]->code.'- '.$chcl[$i+1]->nom_art.'</a></li><br>');

				 	 echo('</ul></div></div></li>');
					//goto end;
					break;
				 }
			}
			    $mem = $chcl[$i]->id_chapitre;	
}	
 ?>
 </ul>
 
</div>

<div id="destination" >
  <h1><?php echo($titre); ?></h1>
  <div id="body">
  
   <div class="CSS_Table_Example" > 
   <table id="myTable" class="tablesorter">
  <thead>
<tr>
   <th>    حوالة الدفع  </th>
    <th>     المبلغ  </th>
   <th>     الالتزام </th>
   <th>    المورد  </th>
  <th>  تسوية </th>
   <th>  مدة الانجاز </th>
   <th>  الاتفاقية </th>
</tr>
</thead>
<?php
$msg=0;
foreach($results as $r) 
{
	$reg=0;
     if($r->is_regularise==1){
	 	$reg='نعم';
	 }else $reg='لا';
	echo '<tr>
	        <td>'.$r->numero_mondat.'</td>
			 <td>'.number_format($r->montant, 2, ',', ' ').'</td>
			<td>'.$r->numero_engagement.'</td>
		    <td>'.$r->nom.'</td>
		    <td>'.$reg.'</td>
		   <td>'.$r->delai_realisation.'</td>
		  <td> <a href="'.base_url('/convention_crt/get_detaille_convention/').'/'.$r->id_convetion.'/'.$msg.'/'.$r->is_regularise.'">'.$r->numero.'</a></td>
		  </tr>'  ;
	
}

 $goupe=$this->session->userdata('user_group'); //access it
  $msg=0; // msg la ne fait rien mais elle indispensable pour appeller ajout_bc et ajout un boton  
?>
</table>
</div>
<div class="pagination_numero">
 <p><?php echo $links; ?></p>
 </div>
  </div>
  
  <div>  
<form  style="position: relative; left: 10%;">
<a href="<?php echo base_url("/budget_ctr/load/")?>" class="botton">خروج</a>
<?php
if($goupe=="admin"){
echo ('<a href="'. base_url('/convention_crt/ajout_convention_new/').'/'.$msg .'" class="botton">اضافة</a>');
}

?>
</form> 
</div>



</div>
  <script>
 $(document).ready(function() 
    { 
        $("#myTable").tablesorter(); 
    } 
); 
 </script>  
  <script>
$(function() {
	var liste_fourniss = <?php echo json_encode($liste_des_fournisseurs); ?>;
	$( "#nom" ).autocomplete({source: liste_fourniss});
	} 
); 
</script> 

</html>